home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 60 / IOPROG_60.ISO / soft / c++ / gsl-1.1.1-setup.exe / {app} / include / gsl / gsl_linalg.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-04-20  |  13.6 KB  |  426 lines

  1. /* linalg/gsl_linalg.h
  2.  * 
  3.  * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, Brian Gough
  4.  * 
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or (at
  8.  * your option) any later version.
  9.  * 
  10.  * This program is distributed in the hope that it will be useful, but
  11.  * WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  * General Public License for more details.
  14.  * 
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. #ifndef __GSL_LINALG_H__
  21. #define __GSL_LINALG_H__
  22.  
  23. #include <gsl/gsl_mode.h>
  24. #include <gsl/gsl_permutation.h>
  25. #include <gsl/gsl_vector.h>
  26. #include <gsl/gsl_matrix.h>
  27.  
  28. #undef __BEGIN_DECLS
  29. #undef __END_DECLS
  30. #ifdef __cplusplus
  31. #define __BEGIN_DECLS extern "C" {
  32. #define __END_DECLS }
  33. #else
  34. #define __BEGIN_DECLS        /* empty */
  35. #define __END_DECLS        /* empty */
  36. #endif
  37.  
  38. __BEGIN_DECLS
  39.  
  40. typedef enum
  41.   {
  42.     GSL_LINALG_MOD_NONE = 0,
  43.     GSL_LINALG_MOD_TRANSPOSE = 1,
  44.     GSL_LINALG_MOD_CONJUGATE = 2
  45.   }
  46. gsl_linalg_matrix_mod_t;
  47.  
  48.  
  49. /* Note: You can now use the gsl_blas_dgemm function instead of matmult */
  50.  
  51. /* Simple implementation of matrix multiply.
  52.  * Calculates C = A.B
  53.  *
  54.  * exceptions: GSL_EBADLEN
  55.  */
  56. int gsl_linalg_matmult (const gsl_matrix * A,
  57.             const gsl_matrix * B,
  58.             gsl_matrix * C);
  59.  
  60.  
  61. /* Simple implementation of matrix multiply.
  62.  * Allows transposition of either matrix, so it
  63.  * can compute A.B or Trans(A).B or A.Trans(B) or Trans(A).Trans(B)
  64.  *
  65.  * exceptions: GSL_EBADLEN
  66.  */
  67. int gsl_linalg_matmult_mod (const gsl_matrix * A,
  68.                 gsl_linalg_matrix_mod_t modA,
  69.                 const gsl_matrix * B,
  70.                 gsl_linalg_matrix_mod_t modB,
  71.                 gsl_matrix * C);
  72.  
  73. /* Calculate the matrix exponential by the scaling and
  74.  * squaring method described in Moler + Van Loan,
  75.  * SIAM Rev 20, 801 (1978). The mode argument allows
  76.  * choosing an optimal strategy, from the table
  77.  * given in the paper, for a given precision.
  78.  *
  79.  * exceptions: GSL_ENOTSQR, GSL_EBADLEN
  80.  */
  81. int gsl_linalg_exponential_ss(
  82.   const gsl_matrix * A,
  83.   gsl_matrix * eA,
  84.   gsl_mode_t mode
  85.   );
  86.  
  87.  
  88. /* Householder Transformations */
  89.  
  90. double gsl_linalg_householder_transform (gsl_vector * v);
  91. gsl_complex gsl_linalg_complex_householder_transform (gsl_vector_complex * v);
  92.  
  93. int gsl_linalg_householder_hm (double tau, 
  94.                                const gsl_vector * v, 
  95.                                gsl_matrix * A);
  96.  
  97. int gsl_linalg_householder_mh (double tau, 
  98.                                const gsl_vector * v, 
  99.                                gsl_matrix * A);
  100.  
  101. int gsl_linalg_householder_hv (double tau, 
  102.                                const gsl_vector * v, 
  103.                                gsl_vector * w);
  104.  
  105. int gsl_linalg_householder_hm1 (double tau, 
  106.                                 gsl_matrix * A);
  107.  
  108. int gsl_linalg_complex_householder_hm (gsl_complex tau, 
  109.                                        const gsl_vector_complex * v, 
  110.                                        gsl_matrix_complex * A);
  111.  
  112. /* Singular Value Decomposition
  113.  
  114.  * exceptions: 
  115.  */
  116.  
  117. int
  118. gsl_linalg_SV_decomp (gsl_matrix * A,
  119.                       gsl_matrix * V,
  120.                       gsl_vector * S,
  121.                       gsl_vector * work);
  122.  
  123. int
  124. gsl_linalg_SV_decomp_mod (gsl_matrix * A,
  125.                           gsl_matrix * X,
  126.                           gsl_matrix * V,
  127.                           gsl_vector * S,
  128.                           gsl_vector * work);
  129.  
  130. int gsl_linalg_SV_decomp_jacobi (gsl_matrix * A,
  131.                                  gsl_matrix * Q,
  132.                                  gsl_vector * S);
  133.  
  134. int
  135. gsl_linalg_SV_solve (const gsl_matrix * U,
  136.                      const gsl_matrix * Q,
  137.                      const gsl_vector * S,
  138.                      const gsl_vector * b,
  139.                      gsl_vector * x);
  140.  
  141.  
  142. /* LU Decomposition, Gaussian elimination with partial pivoting
  143.  */
  144.  
  145. int gsl_linalg_LU_decomp (gsl_matrix * A, gsl_permutation * p, int *signum);
  146.  
  147. int gsl_linalg_LU_solve (const gsl_matrix * LU,
  148.              const gsl_permutation * p,
  149.              const gsl_vector * b,
  150.                          gsl_vector * x);
  151.  
  152. int gsl_linalg_LU_svx (const gsl_matrix * LU,
  153.                        const gsl_permutation * p,
  154.                        gsl_vector * x);
  155.  
  156. int gsl_linalg_LU_refine (const gsl_matrix * A,
  157.               const gsl_matrix * LU,
  158.               const gsl_permutation * p,
  159.               const gsl_vector * b,
  160.               gsl_vector * x,
  161.               gsl_vector * residual);
  162.  
  163. int gsl_linalg_LU_invert (const gsl_matrix * LU,
  164.               const gsl_permutation * p,
  165.               gsl_matrix * inverse);
  166.  
  167. double gsl_linalg_LU_det (gsl_matrix * LU, int signum);
  168. double gsl_linalg_LU_lndet (gsl_matrix * LU);
  169. int gsl_linalg_LU_sgndet (gsl_matrix * lu, int signum);
  170.  
  171. /* Complex LU Decomposition */
  172.  
  173. int gsl_linalg_complex_LU_decomp (gsl_matrix_complex * A, 
  174.                                   gsl_permutation * p, 
  175.                                   int *signum);
  176.  
  177. int gsl_linalg_complex_LU_solve (const gsl_matrix_complex * LU,
  178.                                  const gsl_permutation * p,
  179.                                  const gsl_vector_complex * b,
  180.                                  gsl_vector_complex * x);
  181.  
  182. int gsl_linalg_complex_LU_svx (const gsl_matrix_complex * LU,
  183.                                const gsl_permutation * p,
  184.                                gsl_vector_complex * x);
  185.  
  186. int gsl_linalg_complex_LU_refine (const gsl_matrix_complex * A,
  187.                                   const gsl_matrix_complex * LU,
  188.                                   const gsl_permutation * p,
  189.                                   const gsl_vector_complex * b,
  190.                                   gsl_vector_complex * x,
  191.                                   gsl_vector_complex * residual);
  192.  
  193. int gsl_linalg_complex_LU_invert (const gsl_matrix_complex * LU,
  194.                                   const gsl_permutation * p,
  195.                                   gsl_matrix_complex * inverse);
  196.  
  197. gsl_complex gsl_linalg_complex_LU_det (gsl_matrix_complex * LU,
  198.                                        int signum);
  199.  
  200. double gsl_linalg_complex_LU_lndet (gsl_matrix_complex * LU);
  201.  
  202. gsl_complex gsl_linalg_complex_LU_sgndet (gsl_matrix_complex * LU,
  203.                                           int signum);
  204.  
  205. /* QR decomposition */
  206.  
  207. int gsl_linalg_QR_decomp (gsl_matrix * A,
  208.               gsl_vector * tau);
  209.  
  210. int gsl_linalg_QR_solve (const gsl_matrix * QR,
  211.              const gsl_vector * tau,
  212.              const gsl_vector * b,
  213.              gsl_vector * x);
  214.  
  215. int gsl_linalg_QR_svx (const gsl_matrix * QR,
  216.                        const gsl_vector * tau,
  217.                        gsl_vector * x);
  218.  
  219. int gsl_linalg_QR_lssolve (const gsl_matrix * QR, 
  220.                            const gsl_vector * tau, 
  221.                            const gsl_vector * b, 
  222.                            gsl_vector * x, 
  223.                            gsl_vector * residual);
  224.  
  225.  
  226. int gsl_linalg_QR_QRsolve (gsl_matrix * Q,
  227.                gsl_matrix * R,
  228.                const gsl_vector * b,
  229.                gsl_vector * x);
  230.  
  231. int gsl_linalg_QR_Rsolve (const gsl_matrix * QR,
  232.                           const gsl_vector * b,
  233.               gsl_vector * x);
  234.  
  235. int gsl_linalg_QR_Rsvx (const gsl_matrix * QR,
  236.                         gsl_vector * x);
  237.  
  238. int gsl_linalg_QR_update (gsl_matrix * Q,
  239.               gsl_matrix * R,
  240.               gsl_vector * w,
  241.               const gsl_vector * v);
  242.  
  243. int gsl_linalg_QR_QTvec (const gsl_matrix * QR,
  244.              const gsl_vector * tau,
  245.              gsl_vector * v);
  246.  
  247. int gsl_linalg_QR_Qvec (const gsl_matrix * QR,
  248.                         const gsl_vector * tau,
  249.                         gsl_vector * v);
  250.  
  251. int gsl_linalg_QR_unpack (const gsl_matrix * QR,
  252.               const gsl_vector * tau,
  253.               gsl_matrix * Q,
  254.               gsl_matrix * R);
  255.  
  256. int gsl_linalg_R_solve (const gsl_matrix * R,
  257.                         const gsl_vector * b,
  258.                         gsl_vector * x);
  259.  
  260. int gsl_linalg_R_svx (const gsl_matrix * R,
  261.                       gsl_vector * x);
  262.  
  263.  
  264. /* Q R P^T decomposition */
  265.  
  266. int gsl_linalg_QRPT_decomp (gsl_matrix * A,
  267.                 gsl_vector * tau,
  268.                 gsl_permutation * p,
  269.                 int *signum,
  270.                             gsl_vector * norm);
  271.  
  272. int gsl_linalg_QRPT_decomp2 (const gsl_matrix * A, 
  273.                              gsl_matrix * q, gsl_matrix * r, 
  274.                              gsl_vector * tau, 
  275.                              gsl_permutation * p, 
  276.                              int *signum,
  277.                              gsl_vector * norm);
  278.  
  279. int gsl_linalg_QRPT_solve (const gsl_matrix * QR,
  280.                const gsl_vector * tau,
  281.                const gsl_permutation * p,
  282.                            const gsl_vector * b,
  283.                gsl_vector * x);
  284.  
  285.  
  286. int gsl_linalg_QRPT_svx (const gsl_matrix * QR,
  287.                          const gsl_vector * tau,
  288.                          const gsl_permutation * p,
  289.                          gsl_vector * x);
  290.  
  291. int gsl_linalg_QRPT_QRsolve (const gsl_matrix * Q,
  292.                  const gsl_matrix * R,
  293.                  const gsl_permutation * p,
  294.                  const gsl_vector * b,
  295.                  gsl_vector * x);
  296.  
  297. int gsl_linalg_QRPT_Rsolve (const gsl_matrix * QR,
  298.                              const gsl_permutation * p,
  299.                  const gsl_vector * b,
  300.                              gsl_vector * x);
  301.  
  302. int gsl_linalg_QRPT_Rsvx (const gsl_matrix * QR,
  303.                            const gsl_permutation * p,
  304.                            gsl_vector * x);
  305.  
  306. int gsl_linalg_QRPT_update (gsl_matrix * Q,
  307.                 gsl_matrix * R,
  308.                 const gsl_permutation * p,
  309.                 gsl_vector * u,
  310.                 const gsl_vector * v);
  311.  
  312. /* Cholesky Decomposition */
  313.  
  314. int gsl_linalg_cholesky_decomp (gsl_matrix * A);
  315.  
  316. int gsl_linalg_cholesky_solve (const gsl_matrix * cholesky,
  317.                                const gsl_vector * b,
  318.                                gsl_vector * x);
  319.  
  320. int gsl_linalg_cholesky_svx (const gsl_matrix * cholesky,
  321.                              gsl_vector * x);
  322.  
  323. /* Symmetric to symmetric tridiagonal decomposition */
  324.  
  325. int gsl_linalg_symmtd_decomp (gsl_matrix * A, 
  326.                               gsl_vector * tau);
  327.  
  328. int gsl_linalg_symmtd_unpack (const gsl_matrix * A, 
  329.                               const gsl_vector * tau,
  330.                               gsl_matrix * Q, 
  331.                               gsl_vector * diag, 
  332.                               gsl_vector * subdiag);
  333.  
  334. int gsl_linalg_symmtd_unpack_T (const gsl_matrix * A,
  335.                                 gsl_vector * diag, 
  336.                                 gsl_vector * subdiag);
  337.  
  338. /* Hermitian to symmetric tridiagonal decomposition */
  339.  
  340. int gsl_linalg_hermtd_decomp (gsl_matrix_complex * A, 
  341.                               gsl_vector_complex * tau);
  342.  
  343. int gsl_linalg_hermtd_unpack (const gsl_matrix_complex * A, 
  344.                               const gsl_vector_complex * tau,
  345.                               gsl_matrix_complex * Q, 
  346.                               gsl_vector * diag, 
  347.                               gsl_vector * sudiag);
  348.  
  349. int gsl_linalg_hermtd_unpack_T (const gsl_matrix_complex * A, 
  350.                                 gsl_vector * diag, 
  351.                                 gsl_vector * subdiag);
  352.  
  353. /* Linear Solve Using Householder Transformations
  354.  
  355.  * exceptions: 
  356.  */
  357.  
  358. int gsl_linalg_HH_solve (gsl_matrix * A, const gsl_vector * b, gsl_vector * x);
  359. int gsl_linalg_HH_svx (gsl_matrix * A, gsl_vector * x);
  360.  
  361. /* Linear solve for a symmetric tridiagonal system.
  362.  
  363.  * The input vectors represent the NxN matrix as follows:
  364.  *
  365.  *     diag[0]  offdiag[0]             0    ...
  366.  *  offdiag[0]     diag[1]    offdiag[1]    ...
  367.  *           0  offdiag[1]       diag[2]    ...
  368.  *           0           0    offdiag[2]    ...
  369.  *         ...         ...           ...    ...
  370.  */
  371. int gsl_linalg_solve_symm_tridiag (const gsl_vector * diag,
  372.                    const gsl_vector * offdiag,
  373.                    const gsl_vector * b,
  374.                    gsl_vector * x);
  375.  
  376.  
  377. /* Linear solve for a symmetric cyclic tridiagonal system.
  378.  
  379.  * The input vectors represent the NxN matrix as follows:
  380.  *
  381.  *      diag[0]  offdiag[0]             0   .....  offdiag[N-1]
  382.  *   offdiag[0]     diag[1]    offdiag[1]   .....
  383.  *            0  offdiag[1]       diag[2]   .....
  384.  *            0           0    offdiag[2]   .....
  385.  *          ...         ...
  386.  * offdiag[N-1]         ...
  387.  */
  388. int gsl_linalg_solve_symm_cyc_tridiag (const gsl_vector * diag,
  389.                        const gsl_vector * offdiag,
  390.                        const gsl_vector * b,
  391.                        gsl_vector * x);
  392.  
  393.  
  394. /* Bidiagonal decomposition */
  395.  
  396. int gsl_linalg_bidiag_decomp (gsl_matrix * A, 
  397.                               gsl_vector * tau_U, 
  398.                               gsl_vector * tau_V);
  399.  
  400. int gsl_linalg_bidiag_unpack (const gsl_matrix * A, 
  401.                               const gsl_vector * tau_U, 
  402.                               gsl_matrix * U, 
  403.                               const gsl_vector * tau_V,
  404.                               gsl_matrix * V,
  405.                               gsl_vector * diag, 
  406.                               gsl_vector * superdiag);
  407.  
  408. int gsl_linalg_bidiag_unpack2 (gsl_matrix * A, 
  409.                                gsl_vector * tau_U, 
  410.                                gsl_vector * tau_V,
  411.                                gsl_matrix * V);
  412.  
  413. int gsl_linalg_bidiag_unpack_B (const gsl_matrix * A, 
  414.                                 gsl_vector * diag, 
  415.                                 gsl_vector * superdiag);
  416.  
  417. /* Balancing */
  418.  
  419. int
  420. gsl_linalg_balance_columns (gsl_matrix * A, gsl_vector * D);
  421.  
  422.  
  423. __END_DECLS
  424.  
  425. #endif /* __GSL_LINALG_H__ */
  426.